import React from 'react';

import { Button, Space, message } from 'dw-mx';

import { ExclamationCircleOutlined } from 'dw-mx-icons';
import { Modal } from 'dw-mx';

import { md5, uuid, DateUtil, IDCardUtil } from 'dw-mx-extend';
import moment from 'moment';

export default function Utils() {
    const onConfirm = () => {
        Modal.confirm({
            icon: <ExclamationCircleOutlined />,
            title: '提示',
            content: '提交后将流转到复核岗，将不能修改，是否确定提交？',
            onOk() {
                alert('OK');
            },
            onCancel() {},
        });
    };

    const onMD5 = () => {
        alert(md5('sa'));
    };

    const onUUID = () => {
        alert(uuid());
    };

    const onIDCardUtil = () => {
        alert(IDCardUtil.getCsrqFromSfzhm('110109199611100000'));
    };

    return (
        <div>
            <p>
                <Space>
                    <Button onClick={onConfirm}>confirm</Button>
                    <Button onClick={onMD5}>MD5</Button>
                    <Button onClick={onUUID}>UUID</Button>
                    <Button onClick={onIDCardUtil}>IDCardUtil</Button>
                </Space>
            </p>

            <p>
                <Space>
                    <Button onClick={() => message.info('Time:' + DateUtil.format(new Date(), 'YYYY-MM-DD HH:mm:ss'))}>message-multiple</Button>
                    <Button
                        onClick={() =>
                            message.info({
                                content: 'Time:' + DateUtil.format(new Date(), 'YYYY-MM-DD HH:mm:ss'),
                                duration: 3,
                                key: 'A_UNIQUE_KEY',
                            })
                        }
                    >
                        message-unique
                    </Button>
                </Space>
            </p>

            <p>
                <Space>
                    <Button onClick={() => alert(DateUtil.format(new Date(), 'YYYY-MM-DD HH:mm:ss'))}>DateUtil.format, date</Button>
                    <Button onClick={() => alert(DateUtil.format(moment(), 'YYYY-MM-DD HH:mm:ss'))}>DateUtil.format, moment</Button>
                    <Button onClick={() => alert(DateUtil.stringToDate('2012-12-12 12:12:12', 'YYYY-MM-DD HH:mm:ss'))}>DateUtil.stringToDate</Button>
                    <Button onClick={() => alert(DateUtil.stringToMoment('2012-12-12 12:12:12', 'YYYY-MM-DD HH:mm:ss'))}>DateUtil.stringToMoment</Button>
                </Space>
            </p>
        </div>
    );
}
